/**
 * Copyright 2015-2016 eyaomall.cn
 * All rights reserved.
 *
 * @project
 * @author pro
 * @version 1.0
 * @date 2016-03-07
 */
package com.eyaomall.wxmanage.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.eyaomall.wxmanage.common.enums.MemberCookieEnums;
import com.eyaomall.wxmanage.common.helper.MemberHelper;
import com.eyaomall.wxmanage.model.po.User;
import com.lycheeframework.core.common.cookie.CookieManager;
@Controller
@RequestMapping("/")
public class HomeController {

	/**
	 * 跳转至首页
	 * @param data
	 * @return
	 */
	@RequestMapping("")
	public String index(Map<String,Object> data){
		
		return "home/index";
	}
	
	@RequestMapping("left")
	public String left(String p,String c,Map<String,Object> data){
		data.put("first", p);
		data.put("second", c);
		return "home/left";
	}
	
	/**
	 * 头部菜单
	 * @param cm
	 * @param data
	 * @return
	 */
	@RequestMapping("top")
	public String top(HttpServletRequest request,HttpServletResponse response,String pM,Map<String,Object> data){
		//data.put("pM", pM);
		CookieManager cookie = new CookieManager(request);
		if(!StringUtils.isEmpty(cookie.getValue(MemberCookieEnums._MALL_FORM.getName(), MemberCookieEnums._MALL_FORM_ACCOUNT.getName(), true))){
			User user = new User();
			user.setAccount(MemberHelper.getAccount());
			user.setId(MemberHelper.getId());
			user.setNickName(MemberHelper.getNickName());
			data.put("user", user);
		}
  		return "home/top";
	}
}
